package ee.nutilovi.praktikaportaal.user;

import java.io.IOException;

import javax.servlet.http.*;

@SuppressWarnings("serial")
public class LogoutServlet extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		Cookie[] cookies = req.getCookies();
		for (Cookie cookie : cookies) {
			if (cookie.getName().equals("userId")) {
				cookie.setMaxAge(0);
				resp.addCookie(cookie);
			} else if (cookie.getName().equals("isAdmin")) {
				cookie.setMaxAge(0);
				resp.addCookie(cookie);
			}
		}
		resp.sendRedirect("/");
	}
}
